<template>
  <div>
    <button @click="getStudentsInfo">获取学生信息</button>
    <button @click="getCarsInfo">获取汽车信息</button>
  </div>
</template>

<script>
  // 引入 axios
  import axios from 'axios'

  export default {
      name:'App',
      methods: {
        // 获取学生信息
        getStudentsInfo(){
          axios.get('http://localhost:8080/atguigu/students').then(
            // 成功回调
            response => {
              console.log('请求成功了' ,response.data);
            },

            // 失败回调
            error => {
              console.log('请求失败了' ,error.message);
            }
          )
        },

        // 获取汽车信息
        getCarsInfo(){
          axios.get('http://localhost:8080/demo/cars').then(
            // 成功回调
            response => {
              console.log('请求成功了' ,response.data);
            },

            // 失败回调
            error => {
              console.log('请求失败了' ,error.message);
            }
          )
        }
      }
  }
</script>

<style>

</style>